using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class NetLog_LogUser_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(NetLog.LogUser);
            args = new Type[]{};
            method = type.GetMethod("Connect", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Connect_0);
            args = new Type[]{typeof(huqiang.Communication.UserMsg).MakeByRefType(), typeof(System.String), typeof(System.Byte[])};
            method = type.GetMethod("HandleMsg", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, HandleMsg_1);
            args = new Type[]{};
            method = type.GetMethod("Disconnect", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Disconnect_2);
            args = new Type[]{};
            method = type.GetMethod("Dispose", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Dispose_3);

            field = type.GetField("userType", flag);
            app.RegisterCLRFieldGetter(field, get_userType_0);
            app.RegisterCLRFieldSetter(field, set_userType_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_userType_0, AssignFromStack_userType_0);
            field = type.GetField("LoginDay", flag);
            app.RegisterCLRFieldGetter(field, get_LoginDay_1);
            app.RegisterCLRFieldSetter(field, set_LoginDay_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_LoginDay_1, AssignFromStack_LoginDay_1);
            field = type.GetField("autoRelease", flag);
            app.RegisterCLRFieldGetter(field, get_autoRelease_2);
            app.RegisterCLRFieldSetter(field, set_autoRelease_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_autoRelease_2, AssignFromStack_autoRelease_2);
            field = type.GetField("OnConnected", flag);
            app.RegisterCLRFieldGetter(field, get_OnConnected_3);
            app.RegisterCLRFieldSetter(field, set_OnConnected_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_OnConnected_3, AssignFromStack_OnConnected_3);
            field = type.GetField("handleMsg", flag);
            app.RegisterCLRFieldGetter(field, get_handleMsg_4);
            app.RegisterCLRFieldSetter(field, set_handleMsg_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_handleMsg_4, AssignFromStack_handleMsg_4);


            app.RegisterCLRCreateDefaultInstance(type, () => new NetLog.LogUser());
            app.RegisterCLRCreateArrayInstance(type, s => new NetLog.LogUser[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* Connect_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            NetLog.LogUser instance_of_this_method = (NetLog.LogUser)typeof(NetLog.LogUser).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Connect();

            return __ret;
        }

        static StackObject* HandleMsg_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Byte[] @dat = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @str = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Communication.UserMsg @msg = (huqiang.Communication.UserMsg)typeof(huqiang.Communication.UserMsg).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack), (CLR.Utils.Extensions.TypeFlags)16);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            NetLog.LogUser instance_of_this_method = (NetLog.LogUser)typeof(NetLog.LogUser).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);

            instance_of_this_method.HandleMsg(ref @msg, @str, @dat);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            switch(ptr_of_this_method->ObjectType)
            {
                case ObjectTypes.StackObjectReference:
                    {
                        var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);
                        object ___obj = @msg;
                        if (___dst->ObjectType >= ObjectTypes.Object)
                        {
                            if (___obj is CrossBindingAdaptorType)
                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
                            __mStack[___dst->Value] = ___obj;
                        }
                        else
                        {
                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
                        }
                    }
                    break;
                case ObjectTypes.FieldReference:
                    {
                        var ___obj = __mStack[ptr_of_this_method->Value];
                        if(___obj is ILTypeInstance)
                        {
                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @msg;
                        }
                        else
                        {
                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @msg);
                        }
                    }
                    break;
                case ObjectTypes.StaticFieldReference:
                    {
                        var ___type = __domain.GetType(ptr_of_this_method->Value);
                        if(___type is ILType)
                        {
                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @msg;
                        }
                        else
                        {
                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @msg);
                        }
                    }
                    break;
                 case ObjectTypes.ArrayReference:
                    {
                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as huqiang.Communication.UserMsg[];
                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = @msg;
                    }
                    break;
            }

            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            __intp.Free(ptr_of_this_method);
            return __ret;
        }

        static StackObject* Disconnect_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            NetLog.LogUser instance_of_this_method = (NetLog.LogUser)typeof(NetLog.LogUser).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Disconnect();

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }

        static StackObject* Dispose_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            NetLog.LogUser instance_of_this_method = (NetLog.LogUser)typeof(NetLog.LogUser).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Dispose();

            return __ret;
        }


        static object get_userType_0(ref object o)
        {
            return ((NetLog.LogUser)o).userType;
        }

        static StackObject* CopyToStack_userType_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((NetLog.LogUser)o).userType;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_userType_0(ref object o, object v)
        {
            ((NetLog.LogUser)o).userType = (NetLog.LogUser.UserType)v;
        }

        static StackObject* AssignFromStack_userType_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            NetLog.LogUser.UserType @userType = (NetLog.LogUser.UserType)typeof(NetLog.LogUser.UserType).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)20);
            ((NetLog.LogUser)o).userType = @userType;
            return ptr_of_this_method;
        }

        static object get_LoginDay_1(ref object o)
        {
            return ((NetLog.LogUser)o).LoginDay;
        }

        static StackObject* CopyToStack_LoginDay_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((NetLog.LogUser)o).LoginDay;
            __ret->ObjectType = ObjectTypes.Long;
            *(long*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_LoginDay_1(ref object o, object v)
        {
            ((NetLog.LogUser)o).LoginDay = (System.Int64)v;
        }

        static StackObject* AssignFromStack_LoginDay_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int64 @LoginDay = *(long*)&ptr_of_this_method->Value;
            ((NetLog.LogUser)o).LoginDay = @LoginDay;
            return ptr_of_this_method;
        }

        static object get_autoRelease_2(ref object o)
        {
            return ((NetLog.LogUser)o).autoRelease;
        }

        static StackObject* CopyToStack_autoRelease_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((NetLog.LogUser)o).autoRelease;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }

        static void set_autoRelease_2(ref object o, object v)
        {
            ((NetLog.LogUser)o).autoRelease = (System.Boolean)v;
        }

        static StackObject* AssignFromStack_autoRelease_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Boolean @autoRelease = ptr_of_this_method->Value == 1;
            ((NetLog.LogUser)o).autoRelease = @autoRelease;
            return ptr_of_this_method;
        }

        static object get_OnConnected_3(ref object o)
        {
            return ((NetLog.LogUser)o).OnConnected;
        }

        static StackObject* CopyToStack_OnConnected_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((NetLog.LogUser)o).OnConnected;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_OnConnected_3(ref object o, object v)
        {
            ((NetLog.LogUser)o).OnConnected = (System.Action<NetLog.LogUser>)v;
        }

        static StackObject* AssignFromStack_OnConnected_3(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Action<NetLog.LogUser> @OnConnected = (System.Action<NetLog.LogUser>)typeof(System.Action<NetLog.LogUser>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)8);
            ((NetLog.LogUser)o).OnConnected = @OnConnected;
            return ptr_of_this_method;
        }

        static object get_handleMsg_4(ref object o)
        {
            return ((NetLog.LogUser)o).handleMsg;
        }

        static StackObject* CopyToStack_handleMsg_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((NetLog.LogUser)o).handleMsg;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_handleMsg_4(ref object o, object v)
        {
            ((NetLog.LogUser)o).handleMsg = (System.Action<NetLog.LogUser, huqiang.Communication.UserMsg, System.String, System.Byte[]>)v;
        }

        static StackObject* AssignFromStack_handleMsg_4(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Action<NetLog.LogUser, huqiang.Communication.UserMsg, System.String, System.Byte[]> @handleMsg = (System.Action<NetLog.LogUser, huqiang.Communication.UserMsg, System.String, System.Byte[]>)typeof(System.Action<NetLog.LogUser, huqiang.Communication.UserMsg, System.String, System.Byte[]>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)8);
            ((NetLog.LogUser)o).handleMsg = @handleMsg;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new NetLog.LogUser();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
